package org.nterlearning.datamodel.catalog.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import org.nterlearning.datamodel.catalog.model.CourseRelated;
import org.nterlearning.datamodel.catalog.model.CourseRelatedModel;

import java.io.Serializable;

import java.sql.Types;

/**
 * The base model implementation for the CourseRelated service. Represents a row in the &quot;CATALOG_CourseRelated&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link org.nterlearning.datamodel.catalog.model.CourseRelatedModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link CourseRelatedImpl}.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see CourseRelatedImpl
 * @see org.nterlearning.datamodel.catalog.model.CourseRelated
 * @see org.nterlearning.datamodel.catalog.model.CourseRelatedModel
 * @generated
 */
public class CourseRelatedModelImpl extends BaseModelImpl<CourseRelated>
    implements CourseRelatedModel {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. All methods that expect a course related model instance should use the {@link org.nterlearning.datamodel.catalog.model.CourseRelated} interface instead.
     */
    public static final String TABLE_NAME = "CATALOG_CourseRelated";
    public static final Object[][] TABLE_COLUMNS = {
            { "courseRelatedId", Types.BIGINT },
            { "courseId", Types.BIGINT },
            { "relatedCourseId", Types.BIGINT },
            { "relatedCourseIri", Types.VARCHAR },
            { "relationshipType", Types.VARCHAR }
        };
    public static final String TABLE_SQL_CREATE = "create table CATALOG_CourseRelated (courseRelatedId LONG not null primary key,courseId LONG,relatedCourseId LONG,relatedCourseIri VARCHAR(255) null,relationshipType VARCHAR(50) null)";
    public static final String TABLE_SQL_DROP = "drop table CATALOG_CourseRelated";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.entity.cache.enabled.org.nterlearning.datamodel.catalog.model.CourseRelated"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.finder.cache.enabled.org.nterlearning.datamodel.catalog.model.CourseRelated"),
            true);
    public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.column.bitmask.enabled.org.nterlearning.datamodel.catalog.model.CourseRelated"),
            true);
    public static long COURSEID_COLUMN_BITMASK = 1L;
    public static long RELATEDCOURSEIRI_COLUMN_BITMASK = 2L;
    public static long RELATIONSHIPTYPE_COLUMN_BITMASK = 4L;
    public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
                "lock.expiration.time.org.nterlearning.datamodel.catalog.model.CourseRelated"));
    private static ClassLoader _classLoader = CourseRelated.class.getClassLoader();
    private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
            CourseRelated.class
        };
    private long _courseRelatedId;
    private long _courseId;
    private long _originalCourseId;
    private boolean _setOriginalCourseId;
    private long _relatedCourseId;
    private String _relatedCourseIri;
    private String _originalRelatedCourseIri;
    private String _relationshipType;
    private String _originalRelationshipType;
    private transient ExpandoBridge _expandoBridge;
    private long _columnBitmask;
    private CourseRelated _escapedModelProxy;

    public CourseRelatedModelImpl() {
    }

    public long getPrimaryKey() {
        return _courseRelatedId;
    }

    public void setPrimaryKey(long primaryKey) {
        setCourseRelatedId(primaryKey);
    }

    public Serializable getPrimaryKeyObj() {
        return new Long(_courseRelatedId);
    }

    public void setPrimaryKeyObj(Serializable primaryKeyObj) {
        setPrimaryKey(((Long) primaryKeyObj).longValue());
    }

    public Class<?> getModelClass() {
        return CourseRelated.class;
    }

    public String getModelClassName() {
        return CourseRelated.class.getName();
    }

    public long getCourseRelatedId() {
        return _courseRelatedId;
    }

    public void setCourseRelatedId(long courseRelatedId) {
        _courseRelatedId = courseRelatedId;
    }

    public long getCourseId() {
        return _courseId;
    }

    public void setCourseId(long courseId) {
        _columnBitmask |= COURSEID_COLUMN_BITMASK;

        if (!_setOriginalCourseId) {
            _setOriginalCourseId = true;

            _originalCourseId = _courseId;
        }

        _courseId = courseId;
    }

    public long getOriginalCourseId() {
        return _originalCourseId;
    }

    public long getRelatedCourseId() {
        return _relatedCourseId;
    }

    public void setRelatedCourseId(long relatedCourseId) {
        _relatedCourseId = relatedCourseId;
    }

    public String getRelatedCourseIri() {
        if (_relatedCourseIri == null) {
            return StringPool.BLANK;
        } else {
            return _relatedCourseIri;
        }
    }

    public void setRelatedCourseIri(String relatedCourseIri) {
        _columnBitmask |= RELATEDCOURSEIRI_COLUMN_BITMASK;

        if (_originalRelatedCourseIri == null) {
            _originalRelatedCourseIri = _relatedCourseIri;
        }

        _relatedCourseIri = relatedCourseIri;
    }

    public String getOriginalRelatedCourseIri() {
        return GetterUtil.getString(_originalRelatedCourseIri);
    }

    public String getRelationshipType() {
        if (_relationshipType == null) {
            return StringPool.BLANK;
        } else {
            return _relationshipType;
        }
    }

    public void setRelationshipType(String relationshipType) {
        _columnBitmask |= RELATIONSHIPTYPE_COLUMN_BITMASK;

        if (_originalRelationshipType == null) {
            _originalRelationshipType = _relationshipType;
        }

        _relationshipType = relationshipType;
    }

    public String getOriginalRelationshipType() {
        return GetterUtil.getString(_originalRelationshipType);
    }

    public long getColumnBitmask() {
        return _columnBitmask;
    }

    @Override
    public CourseRelated toEscapedModel() {
        if (_escapedModelProxy == null) {
            _escapedModelProxy = (CourseRelated) ProxyUtil.newProxyInstance(_classLoader,
                    _escapedModelProxyInterfaces,
                    new AutoEscapeBeanHandler(this));
        }

        return _escapedModelProxy;
    }

    @Override
    public ExpandoBridge getExpandoBridge() {
        if (_expandoBridge == null) {
            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
                    CourseRelated.class.getName(), getPrimaryKey());
        }

        return _expandoBridge;
    }

    @Override
    public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
        getExpandoBridge().setAttributes(serviceContext);
    }

    @Override
    public Object clone() {
        CourseRelatedImpl courseRelatedImpl = new CourseRelatedImpl();

        courseRelatedImpl.setCourseRelatedId(getCourseRelatedId());
        courseRelatedImpl.setCourseId(getCourseId());
        courseRelatedImpl.setRelatedCourseId(getRelatedCourseId());
        courseRelatedImpl.setRelatedCourseIri(getRelatedCourseIri());
        courseRelatedImpl.setRelationshipType(getRelationshipType());

        courseRelatedImpl.resetOriginalValues();

        return courseRelatedImpl;
    }

    public int compareTo(CourseRelated courseRelated) {
        long primaryKey = courseRelated.getPrimaryKey();

        if (getPrimaryKey() < primaryKey) {
            return -1;
        } else if (getPrimaryKey() > primaryKey) {
            return 1;
        } else {
            return 0;
        }
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }

        CourseRelated courseRelated = null;

        try {
            courseRelated = (CourseRelated) obj;
        } catch (ClassCastException cce) {
            return false;
        }

        long primaryKey = courseRelated.getPrimaryKey();

        if (getPrimaryKey() == primaryKey) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (int) getPrimaryKey();
    }

    @Override
    public void resetOriginalValues() {
        CourseRelatedModelImpl courseRelatedModelImpl = this;

        courseRelatedModelImpl._originalCourseId = courseRelatedModelImpl._courseId;

        courseRelatedModelImpl._setOriginalCourseId = false;

        courseRelatedModelImpl._originalRelatedCourseIri = courseRelatedModelImpl._relatedCourseIri;

        courseRelatedModelImpl._originalRelationshipType = courseRelatedModelImpl._relationshipType;

        courseRelatedModelImpl._columnBitmask = 0;
    }

    @Override
    public CacheModel<CourseRelated> toCacheModel() {
        CourseRelatedCacheModel courseRelatedCacheModel = new CourseRelatedCacheModel();

        courseRelatedCacheModel.courseRelatedId = getCourseRelatedId();

        courseRelatedCacheModel.courseId = getCourseId();

        courseRelatedCacheModel.relatedCourseId = getRelatedCourseId();

        courseRelatedCacheModel.relatedCourseIri = getRelatedCourseIri();

        String relatedCourseIri = courseRelatedCacheModel.relatedCourseIri;

        if ((relatedCourseIri != null) && (relatedCourseIri.length() == 0)) {
            courseRelatedCacheModel.relatedCourseIri = null;
        }

        courseRelatedCacheModel.relationshipType = getRelationshipType();

        String relationshipType = courseRelatedCacheModel.relationshipType;

        if ((relationshipType != null) && (relationshipType.length() == 0)) {
            courseRelatedCacheModel.relationshipType = null;
        }

        return courseRelatedCacheModel;
    }

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(11);

        sb.append("{courseRelatedId=");
        sb.append(getCourseRelatedId());
        sb.append(", courseId=");
        sb.append(getCourseId());
        sb.append(", relatedCourseId=");
        sb.append(getRelatedCourseId());
        sb.append(", relatedCourseIri=");
        sb.append(getRelatedCourseIri());
        sb.append(", relationshipType=");
        sb.append(getRelationshipType());
        sb.append("}");

        return sb.toString();
    }

    public String toXmlString() {
        StringBundler sb = new StringBundler(19);

        sb.append("<model><model-name>");
        sb.append("org.nterlearning.datamodel.catalog.model.CourseRelated");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>courseRelatedId</column-name><column-value><![CDATA[");
        sb.append(getCourseRelatedId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>courseId</column-name><column-value><![CDATA[");
        sb.append(getCourseId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>relatedCourseId</column-name><column-value><![CDATA[");
        sb.append(getRelatedCourseId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>relatedCourseIri</column-name><column-value><![CDATA[");
        sb.append(getRelatedCourseIri());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>relationshipType</column-name><column-value><![CDATA[");
        sb.append(getRelationshipType());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
